/**
 * 
 */
package sort;

import sort.algorithm.SortStrategy;
import sort.record.Records;
import sort.result.SortResult;
import sort.result.SortResultWatcher;

/**
 * @author masaru-gotou
 *
 */
public class SortExecuter {
	SortStrategy sorter;
	SortResult result;
	Records records;
	Records sorted;
	public SortExecuter(SortStrategy sorter, Records records) {
		this.sorter = sorter;
		this.records = records;
	}

	public void execute() {
		SortResultWatcher watcher = new SortResultWatcher(sorter.getName());
		watcher.start(records);
		sorted = sorter.sort(records.copy());
		watcher.finish(sorted);
		result = watcher.getResult();
	}
	
	public SortResult getResult() {
		return result;
	}

	public Records getRecords() {
		return records;
	}
	
	public Records getSorted() {
		return sorted;
	}
}
